package com.tsxy.Exception;

import com.tsxy.common.APIResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 统一异常处理
 */
@ControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(MyException.class)
    @ResponseBody
    public APIResult handleException(MyException e) {

        return APIResult.error(e.getCode(),e.getMessage());
    }


}
